﻿using System;
using UnityEngine;
using UnityEngine.UI;


public class MenuPanelView : MonoBehaviour
    {
        private void Start()
        {
            InitUI();
        }
        private void InitUI()
        {
            transform.Find("BtnCharacter").GetComponent<Button>().onClick.AddListener(() =>
            {
                //角色按钮点击
                Instantiate(PrefabManager.Instance.CharacterPanel, StartGame.Instance.canvas)
                    .AddComponent<CharacterPanelView>();;
                Destroy(gameObject);
            });
            transform.Find("BtnItem").GetComponent<Button>().onClick.AddListener(() =>
            {
                //角色按钮点击
                Instantiate(PrefabManager.Instance.ItemPanel, StartGame.Instance.canvas)
                    .AddComponent<ItemPanelView>();;
                Destroy(gameObject);
            });
            transform.Find("BtnReturn").GetComponent<Button>().onClick.AddListener(() =>
            {
                //返回按钮点击
                Instantiate(PrefabManager.Instance.LoadDataPanel, StartGame.Instance.canvas)
                    .AddComponent<LoadDataPanelView>();;
                Destroy(gameObject);
            });
            Debug.LogWarning("MenuPanelView  :"+StartGame.Instance._sqlDbConn);
            transform.Find("BtnSave").GetComponent<Button>().onClick.AddListener(() =>
            {
                //返回按钮点击
               CharacterModel.Instance.SaveData(StartGame.Instance._sqlDbConn);
            });
        }
    }
